package pt.ist.meic.pava.JVSTMSync;

import java.lang.reflect.Field;

import org.aspectj.lang.reflect.FieldSignature;

import jvstm.VBox;

public class Box {

	
	private VBox<Object> box;
	
	private FieldSignature signature;// = (FieldSignature)thisJoinPoint.getSignature(); 
	
	private Field field;// = sig.getField(); 
	

	
	public Box(VBox<Object> box, FieldSignature signature) {
		
		this.box = box;
		this.signature = signature;
		
		this.field = signature.getField(); /**do we really need this field?**/
		
	}
	
	
	public Box(FieldSignature signature) {
		
		this.signature = signature;
		
		this.box = new VBox<Object>();
		
		this.field = signature.getField();
		
	}
	
	
	public void setVBox(VBox<Object> box) {
		
		this.box = box;
		
	}
	
	
	public void setSignature(FieldSignature signature) {
		
		this.signature = signature;
		
	}
	
	
	
	public VBox<Object> getVBox() {
		
		return this.box;
		
	}
	
	
	public FieldSignature getSignature() {
		
		return this.signature;
		
	}
	
	
	
	
	/*public boolean itsMe(FieldSignature signature) {
		
		return this.signature.equals(signature);
	
		
	}*/
	
	public boolean itsMe(FieldSignature signature) {
		
		Field f = signature.getField();
		Class<?> c = signature.getField().getDeclaringClass();
		
		
		if(this.field.equals(f) && this.field.getDeclaringClass().equals(c))
			return true;
		else
			return false;
	
	}
	
	
	public Object get() {
		
		return this.box.get();
		
	}
	
	public void put(Object newE) {
		this.box.put(newE);
	}
	
	
}
